<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Understand Sentences</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Understand Sentences' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">if</a></li><li><a href="index.html#5">Chapter 5: Command Parser</a></li><li><b>Understand Sentences</b></li></ul></div>
<p class="purpose">Command parser grammar is laid out in special Understand... sentences.</p>

<ul class="toc"><li><a href="5-us.html#SP1">&#167;1. Traversing</a></li><li><a href="5-us.html#SP4">&#167;4. The subject phrase</a></li><li><a href="5-us.html#SP7">&#167;7. Object phrases I: Understand explicit grammar</a></li><li><a href="5-us.html#SP12">&#167;12. Object phrases II: Understand the command</a></li><li><a href="5-us.html#SP13">&#167;13. Object phrases III: Understand the property</a></li><li><a href="5-us.html#SP14">&#167;14. Handling object phrase depending on subject phrase</a></li><li><a href="5-us.html#SP15">&#167;15. Command blocks</a></li><li><a href="5-us.html#SP16">&#167;16. Property blocks</a></li><li><a href="5-us.html#SP17">&#167;17. Nothing blocks</a></li><li><a href="5-us.html#SP18">&#167;18. The other way quoted grammar arises</a></li><li><a href="5-us.html#SP19">&#167;19. Text blocks</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Traversing.</b>When the "parser" feature is active, any sentence in the form "Understand...
as..." is considered to be an instruction about the command grammar, which
is a special data structure created by Inform for the use of the command
parser at run-time.
</p>

<p class="commentary">Such sentences share a single special meaning:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::make_special_meanings</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Understand::make_special_meanings</span></span>:<br/>Parsing Plugin - <a href="5-pp.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SpecialMeanings::declare</span><span class="plain-syntax">(</span><a href="5-us.html#SP3" class="function-link"><span class="function-syntax">Understand::understand_as_SMF</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"understand-as"</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Understand sentences are not read in the main assertion traverse, since they
depend on too much not known then: they have a traverse of their own. See
<a href="5-pp.html#SP2" class="internal">ParsingPlugin::production_line</a> for how it slots in.
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">TRAVERSE_FOR_GRAMMAR_SMFT</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::traverse</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Understand::traverse</span></span>:<br/>Parsing Plugin - <a href="5-pp.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SyntaxTree::traverse</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><a href="5-us.html#SP2" class="function-link"><span class="function-syntax">Understand::visit</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::visit</span><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Node::get_type</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">) == </span><span class="identifier-syntax">SENTENCE_NT</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MajorNodes::try_special_meaning</span><span class="plain-syntax">(</span><span class="constant-syntax">TRAVERSE_FOR_GRAMMAR_SMFT</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Understand sentences are always accepted: that is, any sentence at all in
the "Understand... as..." shape will pass the <span class="extract"><span class="extract-syntax">ACCEPT_SMFT</span></span> traverse. But
such a sentence is then not acted upon in the regular assertion traverses,
as noted above, and instead we wait until <a href="5-us.html#SP2" class="internal">Understand::visit</a> causes
the following to be called.
</p>

<p class="commentary">The practical result is that <a href="5-us.html#SP14" class="internal">Understand::understand_sentence</a> is called
on each such sentence in turn.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::understand_as_SMF</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Understand::understand_as_SMF</span></span>:<br/><a href="5-us.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> *</span><span class="identifier-syntax">NPs</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">OW</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">NPs</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">NPs</span><span class="plain-syntax">[1]):</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">O2W</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">NPs</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">NPs</span><span class="plain-syntax">[2]):</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax">) { </span><span class="comment-syntax"> "Understand... as..."</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">ACCEPT_SMFT:</span>
<span class="plain-syntax">            </span><span class="function-syntax">&lt;np-unparsed&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">O2W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="function-syntax">&lt;np-unparsed&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">OW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRAVERSE_FOR_GRAMMAR_SMFT:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><a href="5-us.html#SP14" class="function-link"><span class="function-syntax">Understand::understand_sentence</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">), </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. The subject phrase.</b>Understand sentences take several different forms &mdash; so different, in fact,
that we will parse the subject phrase to see which form we have, and only then
parse the object phrase (using a different grammar for each of the forms).
As examples:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Understand</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">pot</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">Understand</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">unbroken</span><span class="plain-syntax"> </span><span class="identifier-syntax">property</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">describing</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">pot</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">Understand</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">command</span><span class="plain-syntax"> </span><span class="string-syntax">"access"</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="string-syntax">"open"</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">Understand</span><span class="plain-syntax"> </span><span class="string-syntax">"earthenware"</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">pot</span><span class="plain-syntax">. </span><span class="identifier-syntax">Understand</span><span class="plain-syntax"> </span><span class="string-syntax">"photograph [something]"</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">photographing</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary">&lt;understand-sentence-sp&gt; has, as its integer result, one of these:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">COMMAND_UNDERSTAND_FORM</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">PROPERTY_UNDERSTAND_FORM</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">GRAMMAR_UNDERSTAND_FORM</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">NOTHING_UNDERSTAND_FORM</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">NO_UNDERSTAND_FORM</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>As its pointer result, it has a pointer to a linked list of the following
objects, which are really just unions of being a text in quotes or a property name:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">quoted_property</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::text_item</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Understand::text_item</span></span>:<br/><a href="5-us.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">preform_lookahead_mode</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_property</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ui</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::property_item</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Understand::property_item</span></span>:<br/><a href="5-us.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">preform_lookahead_mode</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_property</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ui</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::list_ui</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Understand::list_ui</span></span>:<br/><a href="5-us.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui1</span><span class="plain-syntax">, </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ui1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ui2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ui2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ui1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ui1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ui1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure understanding_item is accessed in 2/ri, 3/tm, 3/scn, 3/ts, 3/mhr, 4/ap, 4/av, 4/apc, 6/db, 6/dl, 6/dc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>So, then, the Preform for the subject phrase is as follows:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;understand-sentence-sp&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">command</span><span class="plain-syntax">/</span><span class="identifier-syntax">commands</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-reg-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb</span><span class="plain-syntax">/</span><span class="identifier-syntax">verbs</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-reg-list&gt;</span>

<span class="function-syntax">&lt;understand-reg-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-reg-entry&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-reg-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-reg-entry&gt;</span>

<span class="function-syntax">&lt;understand-reg-tail&gt;</span>
<span class="plain-syntax">    , </span><span class="identifier-syntax">_and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-reg-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-reg-list&gt;</span>

<span class="function-syntax">&lt;understand-reg-entry&gt;</span>
<span class="plain-syntax">    ...</span>

<span class="function-syntax">&lt;understand-prop-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-entry&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-prop-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-entry&gt;</span>

<span class="function-syntax">&lt;understand-prop-tail&gt;</span>
<span class="plain-syntax">    , </span><span class="identifier-syntax">_and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-prop-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-prop-list&gt;</span>

<span class="function-syntax">&lt;understand-prop-entry&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;property-name&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">property</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">property</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6_1" class="paragraph-anchor"></a><b>&#167;6.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_OldVerbUsage problem</span><span class="named-paragraph-number">6.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_OldVerbUsage</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this is an outdated form of words"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"and Inform now prefers 'Understand the command ...' rather than 'Understand "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the verb ...'. (Since this change was made in beta-testing, quite a few old "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"source texts still use the old form: the authors of Inform apologise for "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"any nuisance incurred.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">NO_UNDERSTAND_FORM</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_2" class="paragraph-anchor"></a><b>&#167;6.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_UnknownUnderstandProperty problem</span><span class="named-paragraph-number">6.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (!</span><span class="identifier-syntax">preform_lookahead_mode</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnknownUnderstandProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"I don't understand what property that refers to"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"but it doesn't seem to be a property I know. An example of "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"correct usage is 'understand the transparent property as "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"describing a container.'"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Object phrases I: Understand explicit grammar.</b>We use three different Preform grammars to parse the object phrase depending on
the form of the sentence, and this is the commonest, shared by the
<span class="extract"><span class="extract-syntax">GRAMMAR_UNDERSTAND_FORM</span></span> and <span class="extract"><span class="extract-syntax">NOTHING_UNDERSTAND_FORM</span></span>. It handles sentences like:
</p>

<blockquote>
    <p>Understand "take [something]" as taking.</p>
</blockquote>

<p class="commentary">It's not widely known, but the object phrase here can be a list:
</p>

<blockquote>
    <p>Understand "broken" as the pot, the shovel or the contract.</p>
</blockquote>

<p class="commentary">The nonterminal &lt;understand-sentence-op&gt; returns <span class="extract"><span class="extract-syntax">TRUE</span></span> or <span class="extract"><span class="extract-syntax">FALSE</span></span> in its
integer return value according to whether a when condition is supplied, or not.
Its pointer return value is once again a linked list of objects, but this time
they are <a href="5-us.html#SP7" class="internal">understanding_reference</a> objects:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">reference_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">cg_result</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">mistaken</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">mistake_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">pluralised_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">reversed_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">property_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">token_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">when_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::list_ur</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Understand::list_ur</span></span>:<br/><a href="5-us.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur1</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ur1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ur2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure understanding_reference is accessed in 2/ri, 3/tm, 3/scn, 3/ts, 3/mhr, 4/ap, 4/av, 4/apc, 5/cgl, 6/db, 6/dl, 6/dc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>Unlike the case above, though, we will build these more complicated objects
in a multi-stage way. There is always one being built; when we're done, we
call <a href="5-us.html#SP8" class="internal">Understand::preserve_ur</a> to obtain a permanent record of it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::initialise_ur</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Understand::initialise_ur</span></span>:<br/><a href="5-us.html#SP10_1">&#167;10.1</a>, <a href="5-us.html#SP18">&#167;18</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">reference_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_SUBJECT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">mistaken</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">mistake_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pluralised_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">reversed_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">an_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">property_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">when_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::preserve_ur</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Understand::preserve_ur</span></span>:<br/><a href="5-us.html#SP10_9">&#167;10.9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    *</span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>Now we turn to the object phrase.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;understand-text-op&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-text-op-uncond&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">when</span><span class="plain-syntax">/</span><span class="reserved-syntax">while</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-text-op-uncond&gt;</span>

<span class="function-syntax">&lt;understand-text-op-uncond&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-text-entry&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-text-op-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-text-entry&gt;</span>

<span class="function-syntax">&lt;understand-text-op-tail&gt;</span>
<span class="plain-syntax">    , </span><span class="identifier-syntax">_and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-text-op-uncond&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-text-op-uncond&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>The following grammar is applied to each item in the list in turn, and
looks odd but is actually quite simple: if it matches against one of the
possible notations, the temporary <span class="extract"><span class="extract-syntax">ur_being_parsed</span></span> object is annotated;
if this succeeds without problem messages, that temporary object is
converted into a permanent <a href="5-us.html#SP7" class="internal">understanding_reference</a>.
</p>

<p class="commentary">&lt;understand-as-this&gt; and &lt;understand-ref&gt; has no pointer result, and their
integer result is 0 if no problems were thrown, or -1 if they were.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;understand-text-entry&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-as-this&gt;</span>

<span class="function-syntax">&lt;understand-as-this&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">mistake</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">mistake</span><span class="plain-syntax"> ( </span><span class="function-syntax">&lt;quoted-text&gt;</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">mistake</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">plural</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-ref&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">plural</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-ref&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;quoted-text&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-ref&gt;</span><span class="plain-syntax"> ( </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">nouns</span><span class="plain-syntax"> </span><span class="identifier-syntax">reversed</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-ref&gt;</span>

<span class="function-syntax">&lt;understand-ref&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;action-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;action-pattern&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;s-descriptive-type-expression&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;s-variable&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10_1" class="paragraph-anchor"></a><b>&#167;10.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Begin parsing an understand reference</span><span class="named-paragraph-number">10.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><a href="5-us.html#SP8" class="function-link"><span class="function-syntax">Understand::initialise_ur</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> and thus continue with the nonterminal</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_2" class="paragraph-anchor"></a><b>&#167;10.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Mistake</span><span class="named-paragraph-number">10.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_COMMAND</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">mistaken</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">mistake_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_3" class="paragraph-anchor"></a><b>&#167;10.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Mistake with text</span><span class="named-paragraph-number">10.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_COMMAND</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">mistaken</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">mistake_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::one_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">[1]);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_4" class="paragraph-anchor"></a><b>&#167;10.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Pluralise</span><span class="named-paragraph-number">10.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">pluralised_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP10_5" class="paragraph-anchor"></a><b>&#167;10.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make into a token</span><span class="named-paragraph-number">10.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_TOKEN</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">token_text</span><span class="plain-syntax"> = </span><a href="5-cgt.html#SP2" class="function-link"><span class="function-syntax">CGTokens::break</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">reference_text</span><span class="plain-syntax">)), </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_6" class="paragraph-anchor"></a><b>&#167;10.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Reverse</span><span class="named-paragraph-number">10.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">reversed_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_7" class="paragraph-anchor"></a><b>&#167;10.7. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Add action reference</span><span class="named-paragraph-number">10.7</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_COMMAND</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">an_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1];</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_8" class="paragraph-anchor"></a><b>&#167;10.8. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Add specification reference</span><span class="named-paragraph-number">10.8</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">ur_being_parsed</span><span class="plain-syntax">.</span><span class="element-syntax">spec_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1];</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_9" class="paragraph-anchor"></a><b>&#167;10.9. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Preserve the results</span><span class="named-paragraph-number">10.9</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax">[1] == -1) { </span><span class="comment-syntax"> i.e., if a problem was thrown</span>
<span class="plain-syntax">        ==&gt; { -, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        ==&gt; { -, </span><a href="5-us.html#SP8" class="function-link"><span class="function-syntax">Understand::preserve_ur</span></a><span class="plain-syntax">() };</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_10" class="paragraph-anchor"></a><b>&#167;10.10. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_TextlessMistake problem</span><span class="named-paragraph-number">10.10</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TextlessMistake</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"when 'understand' results in a mistake it can only be followed by a textual "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"message in brackets"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"so for instance 'understand \"take\" as a mistake (\"In this sort of game, "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a noun is required there.\").'"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_11" class="paragraph-anchor"></a><b>&#167;10.11. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_UnderstandVariable problem</span><span class="named-paragraph-number">10.11</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Offending pseudo-meaning is: %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandVariable</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this meaning is a value that varies"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"whereas I need something fixed. (The most common case of this is saying "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"that something should be understood as 'the player', which is actually a "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"variable, because the perspective of play can change. Writing 'yourself' "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"instead will usually do.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_12" class="paragraph-anchor"></a><b>&#167;10.12. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_UnderstandActionPattern problem</span><span class="named-paragraph-number">10.12</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Offending pseudo-meaning is: %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandActionPattern</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this meaning looks like a form of action"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"but needs to be written more simply, just as the action itself and without "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"any details about what is acted on. For example, 'Understand ... as examining' "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"is fine, but 'Understand ... as examining a door' is not. (What will be "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"examined depends on what is in the actual command this 'Understand' "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"instruction will try to work on - we cannot know yet whether it will be "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a door.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_13" class="paragraph-anchor"></a><b>&#167;10.13. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_UnderstandVague problem</span><span class="named-paragraph-number">10.13</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Offending pseudo-meaning is: %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-us.html#SP11" class="function-link"><span class="function-syntax">Understand::issue_PM_UnderstandVague</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::issue_PM_UnderstandVague</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">Understand::issue_PM_UnderstandVague</span></span>:<br/><a href="5-us.html#SP10_13">&#167;10.13</a>, <a href="5-us.html#SP19_5_1">&#167;19.5.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandVague</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'understand ... as ...' should be followed by a meaning"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which might be an action (e.g., 'understand \"take [something]\" as taking'), "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a thing ('understand \"stove\" as the oven') or more generally a value "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"('understand \"huitante\" as 80'), or a named token for use in further "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"grammar ('understand \"near [something]\" as \"[location phrase]\"'). "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Also, the meaning needs to be precise, so 'understand \"x\" as a number' "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"is not allowed - it does not say which number."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Object phrases II: Understand the command.</b>The second form of the sentence has an object phrase like so:
</p>

<blockquote>
    <p>Understand the command "snatch" as "take".</p>
</blockquote>

<p class="commentary">Here the grammar is very simple, and the object can't be a list.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;understand-command-op&gt;</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">when</span><span class="plain-syntax">/</span><span class="reserved-syntax">while</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">something</span><span class="plain-syntax"> </span><span class="identifier-syntax">new</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;quoted-text&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12_1" class="paragraph-anchor"></a><b>&#167;12.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_UnderstandCommandWhen problem</span><span class="named-paragraph-number">12.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandCommandWhen</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'understand the command ... as ...' is not allowed to have a '... when ...' "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"clause"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"for the moment at any rate."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_2" class="paragraph-anchor"></a><b>&#167;12.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_NotOldCommand problem</span><span class="named-paragraph-number">12.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP12_2_1" class="named-paragraph-link"><span class="named-paragraph">Actually issue PM_NotOldCommand problem</span><span class="named-paragraph-number">12.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    ==&gt; { -1, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_2_1" class="paragraph-anchor"></a><b>&#167;12.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Actually issue PM_NotOldCommand problem</span><span class="named-paragraph-number">12.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_NotOldCommand</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'understand the command ... as ...' should end with a command "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"already defined"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"as in 'understand the command \"steal\" as \"take\"'. (This problem is "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"sometimes seen when the wrong sort of Understand... sentence has been used: "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'Understand the command \"steal\" as \"take\".' tells me to treat the "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"command STEAL as a synonym for TAKE when reading the player's commands, "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"whereas 'Understand \"steal [something]\" as taking.' tells me that here is "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a specific grammar for what can be said using the STEAL command.)"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP12_2">&#167;12.2</a> and <a href="5-us.html#SP15_3">&#167;15.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Object phrases III: Understand the property.</b>The third and final form of the sentence has an object phrase like so:
</p>

<blockquote>
    <p>Understand the unbroken property as describing the pot.</p>
</blockquote>

<p class="commentary">Once again, the object can't be a list.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;understand-prop-op&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-op-uncond&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">when</span><span class="plain-syntax">/</span><span class="reserved-syntax">while</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-op-uncond&gt;</span>

<span class="function-syntax">&lt;understand-prop-op-uncond&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">referring</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-prop-ref&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">describing</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;understand-prop-ref&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ...</span>

<span class="function-syntax">&lt;understand-prop-ref&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;k-kind&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;instance&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13_1" class="paragraph-anchor"></a><b>&#167;13.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_BadUnderstandProperty problem</span><span class="named-paragraph-number">13.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadUnderstandProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"'understand the ... property as ...' is only allowed if followed by 'describing "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"...' or 'referring to ...'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"so for instance 'understand the transparent property as describing a container.'"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">0</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13_2" class="paragraph-anchor"></a><b>&#167;13.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_BadUnderstandPropertyAs problem</span><span class="named-paragraph-number">13.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadUnderstandPropertyAs</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"I don't understand what single thing or kind of thing that refers to"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"but it does need to be an object (or kind of object)."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { -, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax"> };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Handling object phrase depending on subject phrase.</b>So now we use the above Preform: on the sentence "Understand SP as OP", we
parse the subject phrase SP with &lt;understand-sentence-sp&gt;, and depending
on which of the forms it has, we then use one of &lt;understand-command-op&gt;,
&lt;understand-prop-op&gt; or &lt;understand-text-op&gt; on the OP.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::understand_sentence</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">Understand::understand_sentence</span></span>:<br/><a href="5-us.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">ASW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR</span><span class="plain-syntax">, </span><span class="string-syntax">"Parsing understand &lt;%W&gt; as &lt;%W&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">ASW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-sentence-sp&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui_list</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">form</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">form</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">COMMAND_UNDERSTAND_FORM:</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP14_1" class="named-paragraph-link"><span class="named-paragraph">Process Understand command</span><span class="named-paragraph-number">14.1</span></a></span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROPERTY_UNDERSTAND_FORM:</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP14_2" class="named-paragraph-link"><span class="named-paragraph">Process Understand property</span><span class="named-paragraph-number">14.2</span></a></span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">GRAMMAR_UNDERSTAND_FORM:</span><span class="plain-syntax"> </span><span class="comment-syntax"> fall through to...</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NOTHING_UNDERSTAND_FORM:</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP14_3" class="named-paragraph-link"><span class="named-paragraph">Process Understand grammar</span><span class="named-paragraph-number">14.3</span></a></span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14_1" class="paragraph-anchor"></a><b>&#167;14.1. </b>In each case we run through the lists of terms in SP and OP, where lists
are permitted, and for every combination we call exactly one of the four
functions <a href="5-us.html#SP15" class="internal">Understand::command_block</a>, <a href="5-us.html#SP16" class="internal">Understand::property_block</a>,
<a href="5-us.html#SP17" class="internal">Understand::nothing_block</a>, or <a href="5-us.html#SP19" class="internal">Understand::text_block</a>.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Process Understand command</span><span class="named-paragraph-number">14.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-command-op&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = (</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax"> != </span><span class="constant-syntax">0</span><span class="plain-syntax">) ? (</span><span class="identifier-syntax">Wordings::one_word</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">)) : </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="5-us.html#SP15" class="function-link"><span class="function-syntax">Understand::command_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_2" class="paragraph-anchor"></a><b>&#167;14.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Process Understand property</span><span class="named-paragraph-number">14.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-prop-op&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">UW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">UW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;understand-prop-op&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">level</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">level</span><span class="plain-syntax"> = -</span><span class="identifier-syntax">level</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="5-us.html#SP16" class="function-link"><span class="function-syntax">Understand::property_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_property</span><span class="plain-syntax">, </span><span class="identifier-syntax">level</span><span class="plain-syntax">, </span><span class="identifier-syntax">subj</span><span class="plain-syntax">, </span><span class="identifier-syntax">UW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_3" class="paragraph-anchor"></a><b>&#167;14.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Process Understand grammar</span><span class="named-paragraph-number">14.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="function-syntax">&lt;understand-text-op&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur_list</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">UW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax"> == </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">) </span><span class="identifier-syntax">UW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;understand-text-op&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">form</span><span class="plain-syntax"> == </span><span class="constant-syntax">NOTHING_UNDERSTAND_FORM</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><a href="5-us.html#SP17" class="function-link"><span class="function-syntax">Understand::nothing_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">, </span><span class="identifier-syntax">UW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">understanding_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax">; </span><span class="identifier-syntax">ui</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur</span><span class="plain-syntax">; </span><span class="identifier-syntax">ur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">when_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UW</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><a href="5-us.html#SP19" class="function-link"><span class="function-syntax">Understand::text_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ui</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">quoted_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Command blocks.</b>We now define the four "block" functions in turn, beginning with command blocks.
Our aim here is only to perform some semantic checks to see if the instruction
makes sense (as well as being syntactically valid), and then delegate the work
to another section: here <a href="5-cg.html#SP9" class="internal">CommandGrammars::remove_command</a> or <a href="5-cg.html#SP8" class="internal">CommandGrammars::add_alias</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::command_block</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">Understand::command_block</span></span>:<br/><a href="5-us.html#SP14_1">&#167;14.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">ASW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::last_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Word::dequote</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">p</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] == </span><span class="character-syntax">' '</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_SpacyCommand</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'understand the command ... as ...' is only allowed when the old "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"command is a single word"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"so for instance 'understand the command \"capture\" as \"get\"' is "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"okay, but 'understand the command \"capture the flag\" as \"get\"' "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"is not."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::empty</span><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP15_1" class="named-paragraph-link"><span class="named-paragraph">Revoke the command</span><span class="named-paragraph-number">15.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP15_2" class="named-paragraph-link"><span class="named-paragraph">Throw a problem if the command to be defined already means something</span><span class="named-paragraph-number">15.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP15_3" class="named-paragraph-link"><span class="named-paragraph">Define the command</span><span class="named-paragraph-number">15.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15_1" class="paragraph-anchor"></a><b>&#167;15.1. </b>After some debate, we decided that it ought to be legal to declare "Understand the
command "wibble" as something new" even in cases where no "wibble" command existed
already: extensions might want this to assure that they have exclusive use of a
command, for instance. So the following does nothing if <span class="extract"><span class="extract-syntax">cg</span></span> comes back <span class="extract"><span class="extract-syntax">NULL</span></span>, but
does not issue a problem message in that case either.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Revoke the command</span><span class="named-paragraph-number">15.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">command_grammar</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP6" class="function-link"><span class="function-syntax">CommandGrammars::for_command_verb</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cg</span><span class="plain-syntax">) </span><a href="5-cg.html#SP9" class="function-link"><span class="function-syntax">CommandGrammars::remove_command</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cg</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_2" class="paragraph-anchor"></a><b>&#167;15.2. </b>But you can only define a command which does exist already if that command has
no meanings at present &mdash; as can happen if it has had every meaning stripped from
it, one at a time, by previous Understand sentences.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Throw a problem if the command to be defined already means something</span><span class="named-paragraph-number">15.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">command_grammar</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP6" class="function-link"><span class="function-syntax">CommandGrammars::for_command_verb</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cg</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="5-cg.html#SP17" class="function-link"><span class="function-syntax">CommandGrammars::is_empty</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cg</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DESTROY</span><span class="plain-syntax">(</span><span class="identifier-syntax">cg</span><span class="plain-syntax">, </span><span class="reserved-syntax">command_grammar</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_NotNewCommand</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'understand the command ... as ...' is only allowed when the new "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"command has no meaning already"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"so for instance 'understand \"drop\" as \"throw\"' is not allowed "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"because \"drop\" already has a meaning."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP15">&#167;15</a> and <a href="5-us.html#SP15_3">&#167;15.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_3" class="paragraph-anchor"></a><b>&#167;15.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Define the command</span><span class="named-paragraph-number">15.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP15_2" class="named-paragraph-link"><span class="named-paragraph">Throw a problem if the command to be defined already means something</span><span class="named-paragraph-number">15.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Word::dequote</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">command_grammar</span><span class="plain-syntax"> *</span><span class="identifier-syntax">as_gv</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP6" class="function-link"><span class="function-syntax">CommandGrammars::for_command_verb</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ASW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">as_gv</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP12_2_1" class="named-paragraph-link"><span class="named-paragraph">Actually issue PM_NotOldCommand problem</span><span class="named-paragraph-number">12.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="5-cg.html#SP8" class="function-link"><span class="function-syntax">CommandGrammars::add_alias</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">as_gv</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Property blocks.</b>Again, some semantic checks, but the real work is delegated to <a href="5-pv.html#SP2" class="internal">Visibility::set</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::property_block</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">Understand::property_block</span></span>:<br/><a href="5-us.html#SP14_2">&#167;14.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pr</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax">, </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">WHENW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindSubjects::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">subj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InstanceSubjects::to_instance</span><span class="plain-syntax">(</span><span class="identifier-syntax">subj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Instances::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Kinds::Behaviour::is_subkind_of_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandPropertyAsNonObjectKind</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"a property can be understood as referring to a single object (or a kind of "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"object) but not to something of any other kind"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"and this refers to something which is not an object."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">PK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ValueProperties::kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">pr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Properties::is_either_or</span><span class="plain-syntax">(</span><span class="identifier-syntax">pr</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">RTKindConstructors::recognition_only_GPR_provided_by_kit</span><span class="plain-syntax">(</span><span class="identifier-syntax">PK</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">PK</span><span class="plain-syntax">)) ||</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Kinds::Behaviour::is_understandable</span><span class="plain-syntax">(</span><span class="identifier-syntax">PK</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">PK</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ThingReferringProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the value of that property is itself a kind of object"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"so that it cannot be understand as describing or referring to "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"something. I can understand either/or properties, properties "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"with a limited list of named possible values, numbers, times "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"of day, or units."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadReferringProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"that property is of a kind which I can't recognise in "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"typed commands"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"so that it cannot be understand as describing or referring to "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"something. I can understand either/or properties, properties "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"with a limited list of named possible values, numbers, times "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"of day, or units; but certain built-into-Inform kinds of value "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"(like snippet or rulebook, for instance) I can't use."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="5-pv.html#SP2" class="function-link"><span class="function-syntax">Visibility::set</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pr</span><span class="plain-syntax">, </span><span class="identifier-syntax">subj</span><span class="plain-syntax">, </span><span class="identifier-syntax">level</span><span class="plain-syntax">, </span><span class="identifier-syntax">WHENW</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnknownUnpermittedProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"that property is not allowed for the thing or kind in question"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"just as (ordinarily) 'understand the open property as describing a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"device' would not be allowed because it makes no sense to call a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"device 'open'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Nothing blocks.</b>Again, some semantic checks, but the real work is delegated to
<a href="4-act.html#SP7" class="internal">Actions::remove_all_command_grammar</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::nothing_block</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">Understand::nothing_block</span></span>:<br/><a href="5-us.html#SP14_3">&#167;14.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">WHENW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ur</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">an_reference</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandNothingNonAction</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'Understand nothing as ...' must be followed by an action"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"such as 'Understand nothing as taking.'"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">WHENW</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandNothingWhen</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'Understand nothing as ...' must be unconditional"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so your 'when' or 'while' condition will have to go."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">an_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Understand nothing as: $l\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="4-act.html#SP7" class="function-link"><span class="function-syntax">Actions::remove_all_command_grammar</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. The other way quoted grammar arises.</b>This section is primarily about Understand sentences, but Inform also receives
grammar in some other contexts, such as in a table where one column contains
conversation topics to be matched, or in the condition:
</p>

<blockquote>
    <p>if the player's command matches "room [number]", ...</p>
</blockquote>

<p class="commentary">The quoted text here becomes a constant of the kind <span class="extract"><span class="extract-syntax">K_understanding</span></span>, and
when it needs to be compiled, the following function is called. As can be
seen, it funnels directly into <a href="5-us.html#SP19" class="internal">Understand::text_block</a>.
</p>

<p class="commentary">When table cells contain these topics, they are sometimes in the form of a
list: say, "rockets" or "spaceships". We do not police the connectives here,
we simply make any double-quoted text in <span class="extract"><span class="extract-syntax">W</span></span> generate grammar.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">command_grammar</span><span class="plain-syntax"> *</span><span class="function-syntax">Understand::consultation</span><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="5-cg.html#SP15" class="function-link"><span class="function-syntax">CommandGrammars::prepare_consultation_cg</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_WORDING</span><span class="plain-syntax">(</span><span class="identifier-syntax">k</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">TW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::one_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">k</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;quoted-text&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> </span><span class="identifier-syntax">ur</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><a href="5-us.html#SP8" class="function-link"><span class="function-syntax">Understand::initialise_ur</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">ur</span><span class="plain-syntax">, </span><span class="identifier-syntax">TW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ur</span><span class="plain-syntax">.</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_CONSULT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><a href="5-us.html#SP19" class="function-link"><span class="function-syntax">Understand::text_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ur</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="5-cg.html#SP15" class="function-link"><span class="function-syntax">CommandGrammars::get_consultation_cg</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Text blocks.</b>And finally, here we perform a lengthy shopping list of checks for validity, but
then in all cases we create a single new CG line with <a href="5-cgl.html#SP2" class="internal">CGLines::new</a>
and add it to a suitably chosen CG with <a href="5-cg.html#SP17" class="internal">CommandGrammars::add_line</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Understand::text_block</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">Understand::text_block</span></span>:<br/><a href="5-us.html#SP14_3">&#167;14.3</a>, <a href="5-us.html#SP18">&#167;18</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">understanding_reference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ur</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">base_problem_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_1" class="named-paragraph-link"><span class="named-paragraph">The wording W must be a piece of quoted text using square brackets properly</span><span class="named-paragraph-number">19.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_2" class="named-paragraph-link"><span class="named-paragraph">If token text is given, it must be well-formed</span><span class="named-paragraph-number">19.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_3" class="named-paragraph-link"><span class="named-paragraph">Consult grammar cannot have conditions attached</span><span class="named-paragraph-number">19.3</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_4" class="named-paragraph-link"><span class="named-paragraph">Reference cannot be to an object with a qualified description</span><span class="named-paragraph-number">19.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_5" class="named-paragraph-link"><span class="named-paragraph">Reference cannot be imprecise</span><span class="named-paragraph-number">19.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_6" class="named-paragraph-link"><span class="named-paragraph">Reference cannot be to a value of a kind not supporting parsing at run-time</span><span class="named-paragraph-number">19.6</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_7" class="named-paragraph-link"><span class="named-paragraph">Read a reference to a single positive adjective as a noun</span><span class="named-paragraph-number">19.7</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_8" class="named-paragraph-link"><span class="named-paragraph">Only objects can be understood in the plural</span><span class="named-paragraph-number">19.8</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">cg_token</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tokens</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="reserved-syntax">cg_line</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cgl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="reserved-syntax">command_grammar</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_9" class="named-paragraph-link"><span class="named-paragraph">Tokenise the quoted text W into the raw tokens for a CG line</span><span class="named-paragraph-number">19.9</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_10" class="named-paragraph-link"><span class="named-paragraph">Make the new CG line</span><span class="named-paragraph-number">19.10</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_11" class="named-paragraph-link"><span class="named-paragraph">Decide which command grammar the new line should go to</span><span class="named-paragraph-number">19.11</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cg</span><span class="plain-syntax">) </span><a href="5-cg.html#SP17" class="function-link"><span class="function-syntax">CommandGrammars::add_line</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cg</span><span class="plain-syntax">, </span><span class="identifier-syntax">cgl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19_1" class="paragraph-anchor"></a><b>&#167;19.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">The wording W must be a piece of quoted text using square brackets properly</span><span class="named-paragraph-number">19.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;quoted-text&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> == </span><span class="constant-syntax">CG_IS_CONSULT</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">BelievedImpossible</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the topic here should be in the form of a textual description"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"as in 'asking about \"[something]\"'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_NontextualUnderstand</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'understand' should be followed by a textual description"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"as in 'understand \"take [something]\" as taking the noun'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Word::well_formed_text_routine</span><span class="plain-syntax">(</span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">))) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandMismatch</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'understand' should be followed by text in which brackets '[' and ']' match"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so for instance 'understand \"take [something]\" as taking the noun' "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"is fine, but 'understand \"take]\" as taking' is not."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_2" class="paragraph-anchor"></a><b>&#167;19.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">If token text is given, it must be well-formed</span><span class="named-paragraph-number">19.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">cc</span><span class="plain-syntax">=0;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_WORDING</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">compare_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMMA_V</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cc</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Word::dequote</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (*(</span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">))) != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_2_1" class="named-paragraph-link"><span class="named-paragraph">Token name invalid</span><span class="named-paragraph-number">19.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Word::dequote</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (*(</span><span class="identifier-syntax">Lexer::word_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">))) != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_2_1" class="named-paragraph-link"><span class="named-paragraph">Token name invalid</span><span class="named-paragraph-number">19.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cc</span><span class="plain-syntax"> != </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_2_1" class="named-paragraph-link"><span class="named-paragraph">Token name invalid</span><span class="named-paragraph-number">19.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_2_1" class="paragraph-anchor"></a><b>&#167;19.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Token name invalid</span><span class="named-paragraph-number">19.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandAsCompoundText</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"if 'understand ... as ...' gives the meaning as text then it must describe "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a single new token"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"so that 'Understand \"group four/five/six\" as \"[department]\"' is legal "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"(defining a new token \"[department]\", or adding to its definition if it "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"already existed) but 'Understand \"take [thing]\" as \"drop [thing]\"' is "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"not allowed, and would not make sense, because \"drop [thing]\" is a "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"combination of two existing tokens - not a single new one."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19_2">&#167;19.2</a> (three times).</li></ul>
<p class="commentary firstcommentary"><a id="SP19_3" class="paragraph-anchor"></a><b>&#167;19.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Consult grammar cannot have conditions attached</span><span class="named-paragraph-number">19.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">when_text</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> == </span><span class="constant-syntax">CG_IS_CONSULT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">BelievedImpossible</span><span class="plain-syntax">), </span><span class="comment-syntax"> at present, I7 syntax prevents this anyway</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'when' cannot be used with this kind of 'Understand'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"for the time being at least."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_4" class="paragraph-anchor"></a><b>&#167;19.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Reference cannot be to an object with a qualified description</span><span class="named-paragraph-number">19.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::object_exactly_described_if_any</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Descriptions::is_qualified</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Offending description: $T"</span><span class="plain-syntax">, </span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandAsQualified</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"I cannot understand text as meaning an object qualified by relative "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"clauses or properties"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"only a specific thing, a specific value or a kind. (But the same effect "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"can usually be achieved with a 'when' clause. For instance, although "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'Understand \"bad luck\" as the broken mirror' is not allowed, "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'Understand \"bad luck\" as the mirror when the mirror is broken' "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"produces the desired effect.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_5" class="paragraph-anchor"></a><b>&#167;19.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Reference cannot be imprecise</span><span class="named-paragraph-number">19.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Specifications::is_kind_like</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_5_1" class="named-paragraph-link"><span class="named-paragraph">Imprecise</span><span class="named-paragraph-number">19.5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_phrasal</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_5_1" class="named-paragraph-link"><span class="named-paragraph">Imprecise</span><span class="named-paragraph-number">19.5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::is_nothing_object_constant</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="5-us.html#SP19_5_1" class="named-paragraph-link"><span class="named-paragraph">Imprecise</span><span class="named-paragraph-number">19.5.1</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_5_1" class="paragraph-anchor"></a><b>&#167;19.5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Imprecise</span><span class="named-paragraph-number">19.5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><a href="5-us.html#SP11" class="function-link"><span class="function-syntax">Understand::issue_PM_UnderstandVague</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19_5">&#167;19.5</a> (three times).</li></ul>
<p class="commentary firstcommentary"><a id="SP19_6" class="paragraph-anchor"></a><b>&#167;19.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Reference cannot be to a value of a kind not supporting parsing at run-time</span><span class="named-paragraph-number">19.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::is_rvalue</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_kind_of_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_subkind_of_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_VALUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">CON_activity</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandAsActivity</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"this 'understand ... as ...' gives text meaning an activity"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"rather than an action. Since activities happen when Inform decides "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"they need to happen, not in response to typed commands, this doesn't "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"make sense."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_understandable</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandAsBadValue</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"'understand ... as ...' gives text meaning a value whose kind "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"is not allowed"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"and should be a value such as 100."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_7" class="paragraph-anchor"></a><b>&#167;19.7. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Read a reference to a single positive adjective as a noun</span><span class="named-paragraph-number">19.7</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_description</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Descriptions::to_instance</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Kinds::Behaviour::is_subkind_of_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            &amp;&amp; (</span><span class="identifier-syntax">Descriptions::number_of_adjectives_applied_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            &amp;&amp; (</span><span class="identifier-syntax">AdjectivalPredicates::parity</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Propositions::first_unary_predicate</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Specifications::to_proposition</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">adjective</span><span class="plain-syntax"> *</span><span class="identifier-syntax">aph</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">AdjectivalPredicates::to_adjective</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Propositions::first_unary_predicate</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Specifications::to_proposition</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">q</span><span class="plain-syntax"> = </span><span class="identifier-syntax">AdjectiveAmbiguity::has_enumerative_meaning</span><span class="plain-syntax">(</span><span class="identifier-syntax">aph</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">q</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_VALUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::from_instance</span><span class="plain-syntax">(</span><span class="identifier-syntax">q</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">AdjectiveAmbiguity::has_either_or_property_meaning</span><span class="plain-syntax">(</span><span class="identifier-syntax">aph</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> = </span><span class="constant-syntax">CG_IS_PROPERTY_NAME</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">property_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">prn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_8" class="paragraph-anchor"></a><b>&#167;19.8. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Only objects can be understood in the plural</span><span class="named-paragraph-number">19.8</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pluralised_reference</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax"> != </span><span class="constant-syntax">CG_IS_SUBJECT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_UnderstandPluralValue</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'understand' as a plural can only apply to things, rooms or kinds "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"of things or rooms"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so 'Understand \"paperwork\" as the plural of a document.' is fine "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"(assuming a document is a kind of thing), but 'Understand \"dozens\" "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"as the plural of 12' is not."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_9" class="paragraph-anchor"></a><b>&#167;19.9. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Tokenise the quoted text W into the raw tokens for a CG line</span><span class="named-paragraph-number">19.9</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">np</span><span class="plain-syntax"> = </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tokens</span><span class="plain-syntax"> = </span><a href="5-cgt.html#SP4" class="function-link"><span class="function-syntax">CGTokens::tokenise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">np</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_10" class="paragraph-anchor"></a><b>&#167;19.10. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make the new CG line</span><span class="named-paragraph-number">19.10</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">cgl</span><span class="plain-syntax"> = </span><a href="5-cgl.html#SP2" class="function-link"><span class="function-syntax">CGLines::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">an_reference</span><span class="plain-syntax">, </span><span class="identifier-syntax">tokens</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">reversed_reference</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pluralised_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">mistaken</span><span class="plain-syntax">) </span><a href="5-cgl.html#SP13" class="function-link"><span class="function-syntax">CGLines::set_mistake</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cgl</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">mistake_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">when_text</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="5-cgl.html#SP10" class="function-link"><span class="function-syntax">CGLines::set_understand_when</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cgl</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">when_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Descriptions::is_qualified</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="5-cgl.html#SP11" class="function-link"><span class="function-syntax">CGLines::set_understand_prop</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cgl</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Propositions::copy</span><span class="plain-syntax">(</span><span class="identifier-syntax">Descriptions::to_proposition</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Line: $g\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cgl</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP19_11" class="paragraph-anchor"></a><b>&#167;19.11. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Decide which command grammar the new line should go to</span><span class="named-paragraph-number">19.11</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cg_result</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_TOKEN:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to command grammar of token %W: "</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP11" class="function-link"><span class="function-syntax">CommandGrammars::new_named_token</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Wordings::trim_both_ends</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::trim_both_ends</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">token_text</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_COMMAND:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">command_W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">; </span><span class="comment-syntax"> implies the no verb verb</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="5-cgt.html#SP9" class="function-link"><span class="function-syntax">CGTokens::is_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tokens</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">command_W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_word</span><span class="plain-syntax">(</span><a href="5-cgt.html#SP8" class="function-link"><span class="function-syntax">CGTokens::text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tokens</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to command grammar of command '%W': "</span><span class="plain-syntax">, </span><span class="identifier-syntax">command_W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP7" class="function-link"><span class="function-syntax">CommandGrammars::for_command_verb_creating</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">command_W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_SUBJECT:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">target</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::object_exactly_described_if_any</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">target</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Instances::as_subject</span><span class="plain-syntax">(</span><span class="identifier-syntax">target</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_description</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindSubjects::from_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">BelievedImpossible</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"that's not something I can 'Understand ... as ...'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"and should normally be an action or a thing."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to command grammar of subject $j: "</span><span class="plain-syntax">, </span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP13" class="function-link"><span class="function-syntax">CommandGrammars::for_subject</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cg_owner</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_VALUE:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to command grammar of value $P: "</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="5-cgl.html#SP8" class="function-link"><span class="function-syntax">CGLines::set_single_term</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cgl</span><span class="plain-syntax">, </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP14" class="function-link"><span class="function-syntax">CommandGrammars::for_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_kind_of_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">spec_reference</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_PROPERTY_NAME:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to command grammar of property $Y: "</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">property_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP16" class="function-link"><span class="function-syntax">CommandGrammars::for_prn</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ur</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">property_reference</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CG_IS_CONSULT:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"Add to a consultation grammar: "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cg</span><span class="plain-syntax"> = </span><a href="5-cg.html#SP15" class="function-link"><span class="function-syntax">CommandGrammars::get_consultation_cg</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">GRAMMAR_CONSTRUCTION</span><span class="plain-syntax">, </span><span class="string-syntax">"$G\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cg</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-us.html#SP19">&#167;19</a>.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="5-pp.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresschapter"><a href="2-bd.html">2</a></li><li class="progresschapter"><a href="3-sm.html">3</a></li><li class="progresschapter"><a href="4-ap.html">4</a></li><li class="progresscurrentchapter">5</li><li class="progresssection"><a href="5-pp.html">pp</a></li><li class="progresscurrent">us</li><li class="progresssection"><a href="5-cg.html">cg</a></li><li class="progresssection"><a href="5-cgl.html">cgl</a></li><li class="progresssection"><a href="5-cgt.html">cgt</a></li><li class="progresssection"><a href="5-dt.html">dt</a></li><li class="progresssection"><a href="5-pv.html">pv</a></li><li class="progresssection"><a href="5-ts.html">ts</a></li><li class="progresschapter"><a href="6-dlg.html">6</a></li><li class="progressnext"><a href="5-cg.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

